//
//  NuanxinCell.m
//  New
//
//  Created by 才诗琦 on 16/1/20.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "NuanxinCell.h"

@implementation NuanxinCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.imag = [[UIImageView alloc] init];
        _imag.layer.cornerRadius = 5;
        _imag.clipsToBounds = YES;
        [self.contentView addSubview: _imag];
        [_imag release];
        
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 0;
       
        _titleLabel.font = [UIFont systemFontOfSize:18];
        [self.contentView addSubview: _titleLabel];
        [_titleLabel release];
        
        
        self.commentCountLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_commentCountLabel];
        [_commentCountLabel release];
        
        self.timeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_timeLabel];
        [_timeLabel release];
        
        self.comView = [[UIImageView alloc] init];
        [_comView setImage:[UIImage imageNamed:@"xiaoxi1"]];
        [self.contentView addSubview:_comView];
        [_comView release];
       
        
    }
    
    return self;
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
   
    
    self.imag.frame = CGRectMake(10, 10, 100, 100);
    CGFloat h = [[self class] heightWithText:_titleLabel.text];
    self.titleLabel.frame = CGRectMake(120, 10, 240, h);
    
    self.commentCountLabel.frame = CGRectMake(250, h + 40, 70, 30);
    
    self.timeLabel.frame = CGRectMake(120, h + 40, 60, 30);
    
    self.comView.frame = CGRectMake(320, h + 40, 40, 30);
    
}
+ (CGFloat)heightWithText:(NSString *)str
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    
    CGSize size = CGSizeMake(240, 1000);
    
    CGRect rect = [str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size.height;
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
